package com.atguigu.gmall.product.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.to.CategoryTO;
import com.atguigu.gmall.model.product.to.CategoryView;
import com.atguigu.gmall.product.service.BaseCategory3Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/inner/product")
public class CategoryController {

    @Autowired
    BaseCategory3Service baseCategory3Service;

    @GetMapping("/getCategory")
    public Result<List<CategoryTO>> getCategory() {
        List<CategoryTO> categoryTOList = baseCategory3Service.getCategory();
        return Result.ok(categoryTOList);
    }


    @GetMapping("/getCategoryByC3Id/{c3Id}")
    public Result getCategoryByC3Id(@PathVariable Long c3Id) {
        CategoryView categoryView = baseCategory3Service.getCategoryByC3Id(c3Id);
        return Result.ok(categoryView);
    }


}
